package org.extreme.schooltalk;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class MyAdapter extends ArrayAdapter {
	List mList;
	String[] mArrays;
	boolean isStringArrayMode = false;
	Context ctx;
	int resId;
	
	public MyAdapter(Context context, int resId, List list) {
		super(context, resId, list);		
		this.mList = list;
		this.ctx = context;
		this.resId = resId;
	}
	public MyAdapter(Context context, int resId, String[] arrays) {
		super(context, resId, arrays);
		isStringArrayMode = true;
		this.mArrays = arrays;
		this.ctx = context;
		this.resId = resId;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if(convertView == null){
			LayoutInflater inflater = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(resId, null);			
		}
		TextView tv = (TextView)convertView.findViewById(android.R.id.text1);
		
		if(!isStringArrayMode)
			tv.setText((String)mList.get(position));
		else
			tv.setText(mArrays[position]);
		
		tv.setTextColor(Color.WHITE);
		
		return convertView;
	}
	
	

}
